(function webpackUniversalModuleDefinition(root, factory) {
	if(typeof exports === 'object' && typeof module === 'object')
		module.exports = factory();
	else if(typeof define === 'function' && define.amd)
		define("PixiInput", [], factory);
	else if(typeof exports === 'object')
		exports["PixiInput"] = factory();
	else
		root["PixiInput"] = factory();
})(this, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};

/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {

/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId])
/******/ 			return installedModules[moduleId].exports;

/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			exports: {},
/******/ 			id: moduleId,
/******/ 			loaded: false
/******/ 		};

/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);

/******/ 		// Flag the module as loaded
/******/ 		module.loaded = true;

/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}


/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;

/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;

/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";

/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports) {

	/************************/
	/*** The Monkey Patch ***/
	/************************/
	/* We monkey patch autoDetectRenderer() so that
	 * we keep a reference to the mapPositionToPoint method
	 * of the most recently created SystemRenderer
	*/
	"use strict";
	var __extends = (this && this.__extends) || function (d, b) {
	    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
	    function __() { this.constructor = d; }
	    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
	};
	// let mapPositionToPoint: (point: PIXI.Point, x: number, y: number) => PIXI.Point;
	// PIXI.autoDetectRenderer = (function (func: (width: number, height: number, options?: PIXI.RendererOptions, noWebGL?: boolean) => PIXI.WebGLRenderer | PIXI.CanvasRenderer) {
	//     return function (width: number, height: number, options?: PIXI.RendererOptions, noWebGL?: boolean) {
	//         let renderer: PIXI.WebGLRenderer | PIXI.CanvasRenderer = window.capturedRenderer = func(width, height, options, noWebGL);
	//         mapPositionToPoint = renderer.plugins.interaction.mapPositionToPoint.bind(renderer.plugins.interaction);
	//         return renderer;
	//     }
	// })(PIXI.autoDetectRenderer);
	var mapPointToPosition = function (point, x, y) {
	    var rect;
	    // IE 11 fix
	    if (!this.interactionDOMElement.parentElement) {
	        rect = { x: 0, y: 0, width: 0, height: 0 };
	    }
	    else {
	        rect = this.interactionDOMElement.getBoundingClientRect();
	    }
	    console.log(rect);
	    // point.x = ((x - rect.left) * (this.interactionDOMElement.width / rect.width)) / this.resolution;
	    // point.y = ((y - rect.top) * (this.interactionDOMElement.height / rect.height)) / this.resolution;
	    point.x = (x * this.resolution) / (this.interactionDOMElement.width / rect.width) + rect.left;
	    point.y = (y * this.resolution) / (this.interactionDOMElement.height / rect.height) + rect.top;
	    return point;
	};
	PIXI.autoDetectRenderer = (function (func) {
	    return function (width, height, options, noWebGL) {
	        var renderer = window.capturedRenderer = func(width, height, options, noWebGL);
	        mapPointToPosition = mapPointToPosition.bind(renderer.plugins.interaction);
	        return renderer;
	    };
	})(PIXI.autoDetectRenderer);
	/**********************/
	/*** The Text Field ***/
	/**********************/
	var Field = (function (_super) {
	    __extends(Field, _super);
	    function Field() {
	        _super.call(this);
	        this._isTouched = false;
	        this.interactive = true;
	        this._registeredEventListeners = [];
	        this._fieldPosition = new PIXI.Point();
	        this._initGraphics();
	        this._initFieldElement();
	        this._initEvents();
	        this._dev();
	    }
	    Object.defineProperty(Field, "parentDiv", {
	        get: function () { return this._parentDiv; },
	        set: function (value) {
	            this._parentDiv = value;
	            this._canvas = value.querySelector('canvas');
	        },
	        enumerable: true,
	        configurable: true
	    });
	    Object.defineProperty(Field, "canvas", {
	        get: function () { return this._canvas; },
	        enumerable: true,
	        configurable: true
	    });
	    Field.prototype._initGraphics = function () {
	        this.beginFill(0xcccccc);
	        this.drawCircle(0, 0, 50);
	        this.endFill();
	    };
	    Field.prototype._initFieldElement = function () {
	        this._fieldElement = document.createElement('input');
	        Field.parentDiv.insertBefore(this._fieldElement, Field.parentDiv.firstChild);
	        this._fieldElement.style.position = 'absolute';
	        this._fieldElement.style.zIndex = '100';
	    };
	    Field.prototype._initEvents = function () {
	        var _this = this;
	        this._addWindowListener('resize', function (event) {
	            mapPointToPosition(_this._fieldPosition, _this.position.x, _this.position.y);
	            _this._fieldElement.style.transform = 'translate(' + _this._fieldPosition.x + 'px, ' + _this._fieldPosition.y + 'px)';
	            console.error('window resize event');
	        });
	        this.on('positionChanged', function (position) {
	            console.log(position);
	            mapPointToPosition(_this._fieldPosition, position.x, position.y);
	            _this._fieldElement.style.transform = 'translate(' + _this._fieldPosition.x + 'px, ' + _this._fieldPosition.y + 'px)';
	        });
	    };
	    Field.prototype._dev = function () {
	        var _this = this;
	        this.on('mousedown', function (event) {
	            _this._isTouched = true;
	            console.debug('mousedown');
	        });
	        this.on('touchstart', function (event) {
	            _this._isTouched = true;
	            console.debug('mousedown');
	        });
	        this.on('mousemove', function (event) {
	            if (_this._isTouched) {
	                _this.x = event.data.global.x;
	                _this.y = event.data.global.y;
	                console.debug('mousemove');
	            }
	        });
	        this.on('touchmove', function (event) {
	            if (_this._isTouched) {
	                _this.x = event.data.global.x;
	                _this.y = event.data.global.y;
	                console.debug('mousemove');
	            }
	        });
	        this.on('mouseup', function (event) {
	            _this._isTouched = false;
	            console.debug('mouseup');
	        });
	        this.on('touchend', function (event) {
	            _this._isTouched = false;
	            console.debug('mouseup');
	        });
	    };
	    Object.defineProperty(Field.prototype, "x", {
	        set: function (value) {
	            this.position.x = value;
	            this.emit('positionChanged', this.position);
	        },
	        enumerable: true,
	        configurable: true
	    });
	    Object.defineProperty(Field.prototype, "y", {
	        set: function (value) {
	            this.position.y = value;
	            this.emit('positionChanged', this.position);
	        },
	        enumerable: true,
	        configurable: true
	    });
	    /** Adds a listener to the window and keeps a reference to it so the listener can be removed via dispose() */
	    Field.prototype._addWindowListener = function (eventString, func) {
	        this._registeredEventListeners.push([eventString, func]);
	        window.addEventListener(eventString, func);
	    };
	    // Removes all window eventlisteners that this instance has registered
	    Field.prototype.dispose = function () {
	        this._registeredEventListeners.forEach(function (arr) {
	            window.removeEventListener(arr[0], arr[1]);
	        });
	    };
	    return Field;
	}(PIXI.Graphics));
	exports.Field = Field;


/***/ }
/******/ ])
});
;